import Vue from 'vue'
import VueRouter from 'vue-router'
import Favorite from '@views/my/favorite.vue'
import Playlist from '@views/my/playlist.vue'
Vue.use(VueRouter)

const routes = [{
  path: '/',
  redirect: '/index'
}, {
  path: '/index',
  name: 'index',
  component: () => import( /* webpackChunkName: "about" */ '@views/index/index.vue'),


}, {
  path: '/rank',
  name: 'rank',
  component: () => import( /* webpackChunkName: "about" */ '@views/rank/index.vue'),


}, {
  path: '/playlist',
  name: 'playlist',
  component: () => import( /* webpackChunkName: "about" */ '@views/playlist/index.vue'),


}, {
  path: '/playlist/detail',
  name: 'playlistdetail',
  // 懒加载旧写法
  component: () => import( /* webpackChunkName: "about" */ '@views/playlist/detail.vue'),

}, {
  path: '/song',
  name: 'songs',
  component: () => import( /* webpackChunkName: "about" */ '@views/songs/index.vue'),


}, {
  path: '/singer',
  name: 'singer',
  component: () => import( /* webpackChunkName: "about" */ '@views/singer/index.vue'),


}, {
  path: '/album',
  name: 'album',
  component: () => import( /* webpackChunkName: "about" */ '@views/album/index.vue'),


}, {
  path: '/mvlist',
  name: 'mvlist',
  component: () => import( /* webpackChunkName: "about" */ '@views/mv/index.vue'),


}, {
  path: '/mv',
  name: 'mv',
  component: () => import( /* webpackChunkName: "about" */ '@views/mv/detail.vue'),


}, {
  path: '/my',
  name: 'my',
  children: [{
    path: '/my/favorite',
    name: 'myFavorite',
    component: Favorite
  }, {
    path: '/my/playlist',
    name: 'myPlaylist',
    component: Playlist
  }],
  component: () => import( /* webpackChunkName: "about" */ '@views/my/index.vue'),

}, {
  path: '/artist',
  name: 'artist',
  component: () => import( /* webpackChunkName: "about" */ '@views/artist/index.vue'),


}, {
  path: '/search',
  name: 'search',
  component: () => import( /* webpackChunkName: "about" */ '@views/search/index.vue'),


}, {
  path: '/video',
  name: 'video',
  component: () => import( /* webpackChunkName: "about" */ '@views/video/detail.vue'),


}, {
  path: '/user',
  name: 'user',
  component: () => import( /* webpackChunkName: "about" */ '@views/user/index.vue'),


}]

const router = new VueRouter({
  mode: 'history',
  scrollBehavior() {
    return {
      x: 0,
      y: 0
    }
  },
  routes
})
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


export default router
